package lambda;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/5/25 9:40
 * @Copyright 博为峰
 */
public class FnDemo {
    public static void main(String[] args) {
//        m1();
//        m2();
//        m3();
        Predicate<String> predicate = new Predicate<String>() {
            @Override
            public boolean test(String s) {
                return s.equals("张三");
            }
        };

        predicate = s -> s.equals("张三");

        System.out.println(predicate.test("李四"));

    }

    private static void m3() {
        Function<Integer, String> function = new Function<Integer, String>() {
            @Override
            public String apply(Integer integer) {
                return integer.toString();
            }
        };
        function = a -> a.toString();

        System.out.println(function.apply(999));
    }

    private static void m2() {
        Supplier<Integer> supplier = new Supplier<Integer>() {
            @Override
            public Integer get() {
                return 666;
            }
        };

        supplier = () -> 999;

        System.out.println(supplier.get());
    }

    private static void m1() {
        Consumer<String> consumer = new Consumer<String>() {
            @Override
            public void accept(String s) {
//                System.out.println(s);
            }
        };

        consumer = s -> System.out.println(s);

        consumer.accept("LV");
    }
}
